package ma.katrav.web.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.ws.client.core.WebServiceTemplate;

import ma.katrav.oxm.model.Compte;
import ma.katrav.oxm.model.Virement;
import ma.katrav.web.service.CompteService;
import ma.katrav.ws.oxm.model.Retrait;
import ma.katrav.ws.oxm.model.compte.AddCompteRequest;
import ma.katrav.ws.oxm.model.compte.CompteOperationResponse;
import ma.katrav.ws.oxm.model.compte.UpdateCompteRequest;

@Component("compteService")
public class CompteServiceImpl implements CompteService {

	@Autowired @Qualifier("compteWSTemplate")
	private WebServiceTemplate wsTemplate;
	
	public String addCompte(Compte compte) {
		AddCompteRequest request = new AddCompteRequest();
		request.setCompte(compte);
		
		CompteOperationResponse response = (CompteOperationResponse) wsTemplate.marshalSendAndReceive(request);
		
		return response.getResponseDetail().getCodeRetour() + " " + response.getResponseDetail().getDescription();
	}

	public void removeCompte(String codeCompte) {
		// TODO Auto-generated method stub

	}

	public String updateCompte(String codeCompte, Compte compte) {
		UpdateCompteRequest request = new UpdateCompteRequest();
		request.setCompte(compte);
		
		CompteOperationResponse response = (CompteOperationResponse) 
					wsTemplate.marshalSendAndReceive(request);
		
		return response.getResponseDetail().getCodeRetour() + " " + response.getResponseDetail().getDescription();

	}

	public Compte getCompteById(long compteId) {
		// TODO Auto-generated method stub
		return null;
	}

	public Compte getCompteByCode(String codeCompte) {
		// TODO Auto-generated method stub
		return null;
	}

	public Compte getCompteByIntitule(String intitule) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Compte> getListCompte() {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Compte> getListCompteByIntitule(String intitule) {
		// TODO Auto-generated method stub
		return null;
	}

	public void addVirement(Virement virement) {
		// TODO Auto-generated method stub

	}

	public void removeVirement(long virementId) {
		// TODO Auto-generated method stub

	}

	public Virement getVirementById(long virementId) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Virement> getVirementByCodeCompte(String codeCompte) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Virement> getVirementBetweenDate(Date dateD, Date datef) {
		// TODO Auto-generated method stub
		return null;
	}

	public void addRetrait(Retrait retrait) {
		// TODO Auto-generated method stub

	}

	public void removeRetrait(long retraitId) {
		// TODO Auto-generated method stub

	}

	public Retrait getRetraitById(long retraitId) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Retrait> getRetraitByCodeCompte(String codeCompte) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Retrait> getRetraitBetweenDate(Date dateD, Date datef) {
		// TODO Auto-generated method stub
		return null;
	}

}
